package com.example.novelstory.config;

import javax.servlet.MultipartConfigElement;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
//设置文件大小
@Configuration
public class UploadFileConfig {
    @Value("${file.uploadFolder}")
    private String uploadFolder;
    @Bean
    MultipartConfigElement multipartconfigElement(){
    MultipartConfigFactory factory = new MultipartConfigFactory();
    //单个文件最大
    factory.setMaxFileSize(DataSize.ofMegabytes(500));
    //设置总上传数据总大小
    factory.setMaxRequestSize(DataSize.ofMegabytes( 120) );
    return factory.createMultipartConfig();
}

}
